<template>
<div>
    <img src="@/assets/images/wave.jpg" alt="" class="wave" />
  <div class="container">
    <div class="img">
      <img src="@/assets/images/side.svg" alt="" />
    </div>
    <div class="login-container">
      <form action="">
       <div style="display:flex">
          <img class="avatar" src="@/assets/images/user.png" />
        <h2>请先登录</h2>
       </div>
        <div class="input-div one">
          <div class="i"><i></i></div>
          <div>
            <h5 v-if="model.userName==''">用户名</h5>
            <input type="text" class="input" v-model="model.userName"/>
          </div>
        </div>
        <div class="input-div two">
          <div class="i"><i></i></div>
          <div>
            <h5 v-if="model.pwd==''">密码</h5>
            <input type="password" class="input" v-model="model.pwd"/>
          </div>
        </div>
        <input type="submit" value="登录" class="btn" @click="login"/>
      </form>
    </div>
  </div>
</div>
</template>

<script>
export default {
  data() {
    return {
      model: {
        userName: "",
        pwd: "",
      },
    };
  },
  methods: {
    async login() {
      const rs = await this.$http.post("login", this.model);
      if (rs.status !== 200) return;
      sessionStorage.token = rs.data.token;
      console.log('userName:',rs.data.userName);
      this.$router.push("/home");
      this.$message.success("登陆成功");
    },
  },
};
</script>

<style lang="scss" scoped>
.el-input__inner {
  width: 22vw;
}
.loginDiv {
  // display: flex;
  // justify-content: center;
  // align-items: center;
  height: 100%;
}
.el-card {
  margin: 20vh auto;
  width: 30vw;
  height: 20rem;
  margin-right: 20vw;
}
// .itemDIv {
//   display: flex;
//   justify-content: center;
//   margin-right: 5vw;
// }
* {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}

.wave {
  position: fixed;
  height: 100%;
  left: 0;
  bottom: 0;
  z-index: -1;
}

.container {
  width: 100vw;
  height: 100vh;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-gap: 7rem;
  padding: 0 2rem;
}

.img {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  background: transparent;
}

.img img {
  width: 500px;
  background: transparent;
}

.login-container {
  display: flex;
  align-items: center;
  text-align: center;
}

form {
  width: 360px;
}

.avatar {
  width: 100px  !important;
  height: 88px  !important;
}

form h2 {
    font-size: 2.4rem;
    text-transform: uppercase;
    margin: 20px 20px;
    color: #333;
}

.input-div {
  position: relative;
  display: grid;
  grid-template-columns: 7% 93%;
  margin: 25px 0;
  padding: 5px 0;
  border-bottom: 2px solid #d9d9d9;
}

.input-div::after,
.input-div::before {
  content: "";
  position: absolute;
  bottom: -2px;
  width: 0;
  height: 2px;
  background-color: #6c63ff;
  transition: 0.3s;
}

.input-div::after {
  right: 50%;
}

.input-div::before {
  left: 50%;
}

.input-div.focus::after,
.input-div.focus::before {
  width: 50%;
}

.input-div.focus .i i {
  color: #6c63ff;
}

.input-div.focus div h5 {
  top: -5px;
  font-size: 15px;
  color: #6c63ff;
}

.input-div.one {
  margin-top: 0;
}

.input-div.two {
  margin-bottom: 4px;
}

.i {
  display: flex;
  justify-content: center;
  align-items: center;
}

.i i {
  color: #d9d9d9;
  transition: 0.3s;
}

.input-div div {
  position: relative;
  height: 45px;
}

.input-div div h5 {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: #999;
  font-size: 18px;
  transition: 0.3s;
}

.input {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  border: none;
  outline: none;
  background: none;
  padding: 0.5rem 0.7rem;
  font-size: 1.2rem;
  color: #555;
}

a {
  display: block;
  text-align: right;
  text-decoration: none;
  color: #999;
  transition: 0.3s;
}

a:hover {
  color: #6c63ff;
}

.btn {
  display: block;
  width: 100%;
  height: 50px;
  border-radius: 25px;
  margin: 1rem 0;
  font-size: 1.2rem;
  outline: none;
  border: none;
  background-image: linear-gradient(to right, #6c63ff, #5f36aa, #6c63ff);
  cursor: pointer;
  color: #ffffff;
  background-size: 200%;
  transition: 0.5s;
}

.btn:hover {
  background-position: right;
}

@media screen and (max-width: 1100px) {
  .container {
    grid-gap: 3rem;
  }
}

@media screen and (max-width: 980px) {
  form {
    width: 290px;
  }
  form h2 {
    font-size: 2.4rem;
    margin: 8px 0;
  }
  .img img {
    width: 400px;
  }
}

@media screen and (max-width: 900px) {
  .img {
    display: none;
  }
  .container {
    grid-template-columns: 1fr;
  }
  .wave {
    display: none;
  }
  .login-container {
    justify-content: center;
  }
}
</style>
